#! /usr/bin/env python
import os
import sys
import urllib
import urllib2
from optparse import OptionParser

def delete(filename, url):
    d = { 'filename': filename }
    print 'deleting', filename
    req = urllib2.Request(url+"/delete", urllib.urlencode(d))
    f = urllib2.urlopen(req)
    return f.read()


if __name__ == "__main__":
    parser = OptionParser(usage="usage: %prog [options] [files...]")
    parser.add_option("-u", "--url", dest="url", default="http://localhost:8080",
                      help="The URL to upload the airfoil designs to. If not set,"
                           "it defaults to localhost:8080")
    (options, args) = parser.parse_args()
    if len(args) < 1:
        parser.print_help()
        exit(1)

    for filename in args:
        delete(filename,options.url)
